home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_q_t / trem.zip / FOCUS.C < prev    next >
Text File  |  1991-05-11  |  3KB  |  91 lines

  1. /************************************************************************
  2.  *
  3.  *    Copyright (c) 1991 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *-----------------------------------------------------------------------
  6.  *
  7.  *     Project:  Windows Terminal Example
  8.  *
  9.  *      Module:  focus.c
  10.  *
  11.  *      Author:  Bryan A. Woodruff (baw)
  12.  *
  13.  *
  14.  *     Remarks:  Handles the focus (caret creation, destruction)
  15.  *
  16.  *   Revisions:  
  17.  *     01.00.000  5/ 9/91 baw   Wrote it.
  18.  *
  19.  ************************************************************************/
  20.  
  21. #include "terminal.h"
  22.  
  23.  
  24. /************************************************************************
  25.  *  BOOL SetTerminalFocus( HWND hWnd )
  26.  *
  27.  *  Description: 
  28.  *     Sets the focus to the terminal window also creates caret.
  29.  *
  30.  *  Comments:
  31.  *      5/ 9/91  baw  Wrote it.
  32.  *
  33.  ************************************************************************/
  34.  
  35. BOOL SetTerminalFocus( HWND hWnd )
  36. {
  37.    LOCALHANDLE  hTermInfo ;
  38.    NPTERMINFO   npTermInfo ;
  39.  
  40.    hTermInfo = GetWindowWord( hWnd, GWW_TERMINFO ) ;
  41.    if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
  42.       return ( FALSE ) ;
  43.  
  44.    if (npTermInfo -> fConnected && (npTermInfo -> wCursorState != CS_SHOW))
  45.    {
  46.       CreateCaret( hWnd, NULL, npTermInfo -> xChar, npTermInfo -> yChar ) ;
  47.       ShowCaret( hWnd ) ;
  48.       npTermInfo -> wCursorState = CS_SHOW ;
  49.    }
  50.    MoveTerminalCursor( hWnd ) ;
  51.    LocalUnlock( hTermInfo ) ;
  52.    return ( TRUE ) ;
  53.  
  54. } /* end of SetTerminalFocus() */
  55.  
  56. /************************************************************************
  57.  *  BOOL KillTerminalFocus( HWND hWnd )
  58.  *
  59.  *  Description: 
  60.  *     Kills terminal focus.
  61.  *
  62.  *  Comments:
  63.  *      5/ 9/ 91  baw  Wrote it.
  64.  *
  65.  ************************************************************************/
  66.  
  67. BOOL KillTerminalFocus( HWND hWnd )
  68. {
  69.    LOCALHANDLE  hTermInfo ;
  70.    NPTERMINFO   npTermInfo ;
  71.  
  72.    hTermInfo = GetWindowWord( hWnd, GWW_TERMINFO ) ;
  73.    if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
  74.       return ( FALSE ) ;
  75.  
  76.    if (npTermInfo -> fConnected && (npTermInfo -> wCursorState != CS_HIDE))
  77.    {
  78.       HideCaret( hWnd ) ;
  79.       DestroyCaret() ;
  80.       npTermInfo -> wCursorState = CS_HIDE ;
  81.    }
  82.    LocalUnlock( hTermInfo ) ;
  83.    return ( TRUE ) ;
  84.  
  85. } /* end of KillTerminalFocus() */
  86.  
  87. /************************************************************************
  88.  * End of File: focus.c
  89.  ************************************************************************/
  90.  
  91.